package com.ts.api.module.app.config;

import com.gitee.apanlh.web.model.vo.ResultVO;
import com.ts.api.common.constant.BizEnum;
import com.ts.api.exp.BizException;
import com.ts.api.module.channel.entity.po.ChannelFlowConfigPO;
import com.ts.api.module.channel.entity.vo.RespChannelFlowConfigVO;
import com.ts.api.module.channel.service.ChannelConfigService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 *  APP配置
 */
@RestController
@RequestMapping("/app/config")
public class AppConfigController {

    @Autowired
    private ChannelConfigService channelConfigService;

    /**
     *  获取APP配置
     *  <br>拦截等流程配置
     *  @return ResultVO
     */
    @GetMapping("/getHandler")
    public ResultVO<RespChannelFlowConfigVO> getHandler() {
        ChannelFlowConfigPO channelFlowConfigPO = channelConfigService.getFlowConfigByChannelId();
        if (channelFlowConfigPO == null) {
            BizException.fastFail(BizEnum.FLOW_CONFIG_EMPTY);
        }
        return ResultVO.suc(RespChannelFlowConfigVO.convertVO(channelFlowConfigPO));
    }
}
